package com.flyfish.ddns;

import java.io.IOException;

import com.flyfish.ddns.send.UpdateDomainRecord;
import com.flyfish.ddns.utils.PropertiesUtil;
import com.flyfish.ddns.utils.WriteLog;

/**
 * 运行DDNS检查
 *
 */
public class AppRun {

	private static long waitTime = 300;
	static {
		String time = PropertiesUtil.getProperty("waitTime");
		if (time != null && !time.trim().equals("")) {
			waitTime = Long.parseLong(time.trim());
		}
	}

	public static void main(String[] args) throws IOException {
		try {
			while (true) {
				System.out.println("开始ddns检查");
				WriteLog.writeLogInfo("开始ddns检查");
				UpdateDomainRecord demo = new UpdateDomainRecord();
				demo.analysisDns();
				System.out.println("ddns运行结束");
				WriteLog.writeLogInfo("ddns运行结束");
				WriteLog.writeLogInfo("进入线程等待，等待时间：" + waitTime + "秒");
				System.out.println("进入线程等待，等待时间：" + waitTime + "秒");
				Thread.sleep(waitTime * 1000);
			}
		} catch (Exception e) {
			e.printStackTrace();
			WriteLog.writeLogInfo(e.getMessage());
		}
	}
}
